package ch.unisi.inf.gui.action;

import java.io.File;
import javax.swing.ImageIcon;

/**
 * 
 * @author Mohamed.Mosa@lu.unisi.ch
 *
 * This class is responsible for getting the image extensions
 */

public final class Types {

    public final static String gif = "gif";
    public final static String jpeg = "jpeg";
    public final static String jpg = "jpg";
    public final static String png = "png";
    public final static String tiff = "tiff";
    public final static String tif = "tif";

   
    // Get image extension.
    public static final String getExtension(File file) {
        String ext = null;
        String s = file.getName();
        int i = s.lastIndexOf('.');

        if (i > 0 &&  i < s.length() - 1) {
            ext = s.substring(i+1).toLowerCase();
        }
        return ext;
    }
    


    // Here we either print a ImageFileIcon or null if the path is invalid.
    private static final ImageIcon createImageIcon(String path) {
    	System.out.println(System.getProperty("user.dir"));
    	System.out.println("path is: " + path);
        java.net.URL imgURL = Types.class.getResource(path);
        if (imgURL != null) {
            return new ImageIcon(imgURL);
        } else {
            System.err.println("This file could not be found: " + path);
            return null;
        }
    }
}